package com.yanqu.road.server.cmd.activity.dafuweng;

import com.yanqu.road.logic.cross.CrossActivityRankListModel;
import com.yanqu.road.pb.monopoly.MonopolyProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.cross.battle.DaFuWengActivity;
import com.yanqu.road.server.manager.cross.battle.DaFuWengMgr;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_DA_FU_WENG_GET_BOSS_DAMAGE, desc = "怪物伤害信息")
public class CrossGetBossDamageCmd extends CrossUnionCommand {

    int activityId;
    long serverId;
    long userId;
    int bossId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        MonopolyProto.CrossGetDamageRankReqMsg reqMsg = MonopolyProto.CrossGetDamageRankReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        serverId = reqMsg.getServerId();
        userId = reqMsg.getUserId();
        bossId = reqMsg.getBossId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        DaFuWengActivity activity = DaFuWengMgr.getDaFuWengActivity(activityId, groupId);
        if (activity != null) {
            CrossActivityRankListModel monsterRankListModel = activity.getMonsterRankListModel(bossId);

            MonopolyProto.GetDamageRankRespMsg.Builder builder = MonopolyProto.GetDamageRankRespMsg.newBuilder();
            builder.setRet(0);
            builder.setRankList(monsterRankListModel.getRankListMsg());
            YanQuMessage yanQuMessage = YanQuMessageUtils.buildMessage(ClientProtocol.U_DA_FU_WENG_GET_BOSS_DAMAGE, builder);
            MessageHelper.sendPacket(serverId, userId, yanQuMessage);
        }
    }

    @Override
    public void sendData() {

    }
}
